<?php
/**
* @author: trungdt
* 
*/
if (!defined("EXPONENT")) exit("");

$i18n = exponent_lang_loadFile('modules/rsnewsmodule/actions/edit.php');
$save_loc =$loc ;
$rsnews = null;
$iloc = null;
if (isset($_GET['id'])) {
	$rsnews = $db->selectObject("rsnewsitem","id=" . intval($_GET['id']));
}

if ($rsnews != null) {
	$loc = unserialize($rsnews->location_data);
	$iloc = $loc;
	$iloc->int = $rsnews->id;
}

if (($rsnews != null && exponent_permissions_check("edit_item",$loc)) || 
	($rsnews == null && exponent_permissions_check("add_item",$loc)) ||
	($iloc != null   && exponent_permissions_check("edit_item",$iloc)) 
) {
	
	if (!isset($rsnewsmodule_config->image_group)) $rsnewsmodule_config->image_group=0;
	
	$form = rsnewsitem::form($rsnews,$rsnewsmodule_config, $save_loc);
	$form->location($loc);
	$form->meta("action","save");
	$template = new template("rsnewsmodule","_form_edit",$loc);
	$template->assign("form_html",$form->toHTML());
	$template->assign("is_edit", (isset($_GET['id']) ? 1 : 0) );
	$template->output();
} else {
	echo SITE_403_HTML;
}

?>
